import java.util.Stack;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-04-15
 * Time:20:59
 */
public class Text {
    public static boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> B=new Stack<>();
        int j=0;
        for(int i=0;i<pushA.length;i++)
        {
            B.push(pushA[i]);
            while(!B.empty()&&j<popA.length&&B.peek()==popA[j])
            {
                B.pop();
                j++;
            }
        }

        return B.empty();
    }
    public static void main(String[] args) {
        int[] A={1,2,3,4,5,6};
        int[] B={2,3,4,1,5,6};
        System.out.println(IsPopOrder(A,B));
    }
}
